<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>createRef</title>
</head>
<body>
    <script src="../React-js/react.development.js" type="text/javascript"></script>
    <script src="../React-js/react-dom.development.js" type="text/javascript"></script>
    <script src="../React-js/babel.min.js" type="text/javascript"></script>
    <div id="test"></div>
    <script type="text/babel">
        class Demo extends React.Component{
            /*
                React.createRef调用后可以返回一个容器，该容器可以存储被ref所标识的节点，该容器是专人专用的
            */
            myRef = React.createRef()
            myRef1 = React.createRef()
            show = ()=>{
                console.log(this.myRef.current.value);
            }
            show1 = ()=>{
                console.log(this.myRef1.current.value);
            }
            render(){
                return (
                    <div>
                        <input type="text" placeholder="点击显示内容" ref={this.myRef}/>
                        <br />
                        <button onClick={this.show}>点击显示上方内容</button><br />
                        <input type="text" placeholder="失去焦点显示内容" onBlur={this.show1} ref={this.myRef1} />
                    </div>
                )
            }
        }
        ReactDOM.render(<Demo/>,document.querySelector('#test'))
    </script>
</body>
</html>